Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

syntax error, unexpected token “]”

Description

This error appeas when the closing bracket is needed, but not at that place.

In the illustration, the closing square bracket should be not be used directly after a multiplication sign: that operator needs a second operand.

Example

<?php

$a = [3 * 3 * ];

?>

Alternatives

  • Add the missing operand to the previous operator.